package com.itheima;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class Text1 {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        Thread thread = new Thread(new MyThread1());
        thread.start();


        Thread thread1 = new Thread(new MyThread2());
        thread1.start();

        FutureTask<String> ft = new FutureTask<String>(new MyThread3());
        String s = ft.get();

        Thread thread2 = new Thread(ft);
        thread2.start();

        System.out.println("s = " + s);
        System.out.println("thread2 = " + thread2);


    }
}
class MyThread1 extends Thread{
    @Override
    public void run() {
        for (int i = 0; i < 100; i++) {
            System.out.println("i = " + i);
        }
    }
}

class MyThread2 implements Runnable{
    @Override
    public void run() {
        for (int j = 0; j < 100; j++) {
            System.out.println("j = " + j);
        }
    }
}
class MyThread3 implements Callable{
    @Override
    public Object call() throws Exception {
        for (int k = 0; k < 100; k++) {
            System.out.println("k = " + k);
        }
        return "thread3执行完了";
    }
}